# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
# This source file is part of the Cangjie project, licensed under Apache-2.0
# with Runtime Library Exception.
#
# See https://cangjie-lang.cn/pages/LICENSE for license information.


from os import path

operators = ['-', '+', '*', '/', '**']
path = path.dirname(path.realpath(__file__)) + '/test_a03_{}.cj'
template = '''
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
 * This source file is part of the Cangjie project, licensed under Apache-2.0
 * with Runtime Library Exception.
 *
 * See https://cangjie-lang.cn/pages/LICENSE for license information.
 */

/*
  @Assertion:   4.15(3)  The syntax of arithmetic expressions are defined as:
                prefixUnaryExpression
                    : prefixUnaryOperator* incAndDecExpression
                    ;
                prefixUnaryOperator
                    : '-'
                    | ...
                    ;
                additiveExpression
                    : multiplicativeExpression (additiveOperator multiplicativeExpression)*
                    ;
                multiplicativeExpression
                    : exponentExpression (multiplicativeOperator exponentExpression)*
                    ;
                exponentExpression
                    : prefixUnaryExpression (exponentOperator prefixUnaryExpression)*
                    ;
                additiveOperator
                    : '+' | '-'
                    ;
                multiplicativeOperator
                    : '*' | '/' | '%'
                    ;
                exponentOperator
                    : '**'
                    ;
  @Description: Checks that operators {op1} and {op2} together are not permitted.
  @Mode: compileonly
  @Negative: yes
  @Structure: single
  @CompileWarning: no
  @Comment: Auto-generated by gen_suffix.py
*/

main() {{
    let expr = 1.0
    {expr} {op1} {op2} {expr}
}}
'''

counter = 9
    
for op1 in operators:
  for op2 in operators:
    if op2 is '-': continue
    expr = 'Int64(expr)' if op1 is '%' or op2 is '%' else 'expr'
    counter += 1
    content = template.format(op1=op1, op2=op2, expr=expr)
    with open(path.format(str(counter).zfill(2)), 'w') as file:
      file.write(content)
       